package com.zzptc.shop.dao;

import com.zzptc.shop.db.GoodIDB;
import com.zzptc.shop.db.IDB;
import com.zzptc.shop.vo.News;
import com.zzptc.shop.vo.Users;
import com.zzptc.shop.vo.VO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class NewsDao implements IDAO {
    @Override
    public boolean insert(VO vo) throws SQLException {
        return false;
    }

    @Override
    public void updata() throws SQLException {

    }

    @Override
    public boolean delete() throws SQLException {

        return false;
    }

    @Override
    public List<Users> getAll() throws SQLException {
        IDB idb=new GoodIDB();
        Connection connection =idb.getConn();
        PreparedStatement ps=null;
        ResultSet rs=null;
        ps=connection.prepareStatement("select * from easybuy_news");
        rs=ps.executeQuery();
        List list=new ArrayList();
        while (rs.next()){
            News news=new News();
            news.setEn_id(rs.getInt(1));
            news.setEn_title(rs.getString(2));
            news.setEn_content(rs.getString(3));
            news.setEn_create_time(rs.getString(4));
            list.add(news);


        }

        return list;
    }
}
